#include "Camera.h"

template<> Camera* Singleton<Camera>::ms_Singleton = 0;


Camera::Camera()
{
	_rotmatrix = mtxlib::IdentityMatrix44();
	_dist = -5; //hardkod
	_camSpeed = 0.005;
}


void Camera::ApplyCamera()
{
	glTranslatef(0, 0, _dist);
	glMultMatrixf((float*)(&_rotmatrix));
}


mtxlib::matrix44 Camera::GetMatrix()
{
	return mtxlib::TranslateMatrix44(0, 0, _dist) * _rotmatrix;
}


mtxlib::matrix44 Camera::GetRotMatrix()
{
	return _rotmatrix;
}


void Camera::RotateX(float dx)
{
	_rotmatrix = mtxlib::RotateRadMatrix44('x', _camSpeed * dx) * _rotmatrix;
}


void Camera::RotateY(float dy)
{
	_rotmatrix = _rotmatrix * mtxlib::RotateRadMatrix44('z', _camSpeed * dy);// * _rotmatrix;
	//_rotmatrix = mtxlib::RotateRadMatrix44('z', _camSpeed * dy) * _rotmatrix;
}


void Camera::Translate(float d)
{
	_dist += _dist * _camSpeed * d;
}

